﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Client.Service;
using System.Collections;
using GenericModels;
using System.Drawing.Printing;


namespace Client
{
    public partial class Form1 : Form
    {  private IBooking bookingService;
        private Booking foundbooking;
        public Booking booking { get; set; }
        public Customer customer { get; set; }
        public Form1()

        {
            InitializeComponent();
            bookingService = new BookingClient("BasicHttpBinding_IBooking");
            booking = bookingService.GetBookingById(1);
           

        }

        private void button1_Click(object sender, EventArgs e)
        {
            printDokument();
        }

        public void printDokument()
        {

            PrintDialog printDialog = new PrintDialog();
            PrintDocument printdokument = new PrintDocument();
            printDialog.Document = printdokument;
            printdokument.PrintPage += new PrintPageEventHandler(printDocument_PrintPage);
            DialogResult result = printDialog.ShowDialog();
            if (result == DialogResult.OK)
            {
                printdokument.Print();
            }
        }

        private void printDocument_PrintPage(object sender, PrintPageEventArgs e)
        {
            #region test
            //System.Drawing.Graphics graphicsObj;

            //graphicsObj = this.CreateGraphics();

            //Pen myPen = new Pen(System.Drawing.Color.Red, 5);

            //Rectangle myRectangle = new Rectangle(20, 20, 250, 200);

            //graphicsObj.DrawRectangle(myPen, myRectangle);
            #endregion

            Graphics graphic = e.Graphics;
            Font font = new Font("Courier New", 12);
            float fontheight = font.GetHeight();
            int startx = 10;
            int starty = 10;
            int offset = 40;

            graphic.DrawString("Biograf billet", new Font("Courier New", 18), new SolidBrush(Color.Black), startx, starty);

            
                
                string type = booking.PbList[0].TheShow.Type.Title;
                string room = booking.PbList[0].TheShow.Room.RoomNumber.ToString();
                string date = booking.PbList[0].TheShow.Date.ToShortDateString();
                string datetime = booking.PbList[0].TheShow.Date.TimeOfDay.ToString();

                string priceb = String.Format("{0:c}", booking.PbList[0].TheShow.Prices[0].TicketPrice.ToString());

                graphic.DrawString("Film : " + type, font, new SolidBrush(Color.Black), 10, 10 + offset);
                graphic.DrawString("sal : " + room, font, new SolidBrush(Color.Black), 10, 40 + offset);
                graphic.DrawString("Dato : " + date, font, new SolidBrush(Color.Black), 10, 70 + offset);
                graphic.DrawString("Klokken : " + datetime, font, new SolidBrush(Color.Black), 10, 100 + offset);
                graphic.DrawString("Pris : " + priceb, font, new SolidBrush(Color.Black), 10, 130 + offset);
               


                offset = offset + (int)fontheight + 5;

                offset = offset + 20;
          


            //string type = booking.PbList[0].TheShow.Type.Title;
            //string room = booking.PbList[0].TheShow.Room.RoomNumber.ToString();
            //string date = booking.PbList[0].TheShow.Date.Date.ToString();
            //string datetime = booking.PbList[0].TheShow.Date.TimeOfDay.ToString();
            
            //string price = String.Format("{0:c}", booking.PbList[0].TheShow.Prices.ToString()); //Virker ikke helt
            //string seat = booking.PbList[0].Seats.Count.ToString(); //Skal ikke bruges

            //graphic.DrawString(type, font, new SolidBrush(Color.Black), 10, 10 + offset);
            //graphic.DrawString(room, font, new SolidBrush(Color.Black), 10, 40 + offset);
            //graphic.DrawString(date, font, new SolidBrush(Color.Black), 10, 70 + offset);
            //graphic.DrawString(datetime, font, new SolidBrush(Color.Black), 200, 70 + offset);
            //graphic.DrawString(price, font, new SolidBrush(Color.Black), 10, 130 + offset);
            //graphic.DrawString(seat, font, new SolidBrush(Color.Black), 10, 160 + offset);


            //offset = offset + (int)fontheight + 5;

            //offset = offset + 20;


        }
    }
}
